package pl.prv.polanie.client.panels.widgets;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.MouseListenerAdapter;
import com.google.gwt.user.client.ui.Widget;

public class HTMLLink extends HTML {
	
	private static final String STYLE__HTML_LINK = "gwt-HTML-Link";
	private static final String STYLE__HTML_LINK__SELECTED = "gwt-HTML-Link-selected";

	public HTMLLink() {
		setStyleName(STYLE__HTML_LINK);
		addMouseListener();
	}

	public HTMLLink(String html) {
		super(html);
		setStyleName(STYLE__HTML_LINK);
		addMouseListener();
	}

	public HTMLLink(Element element) {
		super(element);
		setStyleName(STYLE__HTML_LINK);
		addMouseListener();
	}

	public HTMLLink(String html, boolean wordWrap) {
		super(html, wordWrap);
		setStyleName(STYLE__HTML_LINK);
		addMouseListener();
	}
	
	private void addMouseListener() {
		addMouseListener(new MouseListenerAdapter() {
			@Override
			public void onMouseEnter(Widget sender) {
				super.onMouseEnter(sender);

				HTMLLink.this.addStyleName(STYLE__HTML_LINK__SELECTED);
			}
			
			@Override
			public void onMouseLeave(Widget sender) {
				super.onMouseLeave(sender);
				
				HTMLLink.this.removeStyleName(STYLE__HTML_LINK__SELECTED);
			}
		});
	}

}
